/*
 * Copyright (c) 2025 Huawei Device, Inc. Ltd. and <马弓手>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef CONFIG_XML_PARSER_H
#define CONFIG_XML_PARSER_H
#include "PluginEntry.h"
#include "XMLParser.h"

/**
 * @brief parse config.xml
 */
class ConfigXmlParser {
    CordovaPreferences* m_preferences{nullptr};
    CXMLParser* m_parser;
    vector<string> m_vecHostName;
    vector<PluginEntry> m_vecPluginEntry;
    string m_strChcpConfigUrl;
    bool m_isAllowUpdatesAutoDownload{false};
    bool m_isAllowUpdatesAutoInstall{false};
    int m_nActiveInterfaceVersion{0}; 
    string m_strWechatAppId;
    vector<string> m_vecProtocolUrl;
    bool m_isStatusBarOverlaysWebView{false};
    string m_strStatusBarBackgroundColor;
    string m_strStatusTextColor;
    string m_strStatusBarStyle;
    bool m_isCameraImageCompress{false};
    long m_lngCompressImageSize{4*1024*1024};
    string m_strCameraCompressShowToast;
    string m_strNavigationBarBackgroundColor;
    string m_strNavigationBarFontColor;
    string m_strNavigationBarFontAlign;
    string m_strNavigationBarLight;
    long m_lngCordovaCacheDuration{24*60*60};
    string m_strIonicHostName;
    string m_strIonicScheme;
    string m_strMinTlsProtocol{"TLSv12"};
public:
    ConfigXmlParser();
    ~ConfigXmlParser();
    void parseXml();
    vector<PluginEntry>* getPluginEntry();
    /**
     * @brief Gets Preferences of config.xml
     * @return Preferences pointer
     */
    CordovaPreferences* getCordovaPreferences();
    /**
     * @brief All functions below are used to retrieve corresponding values. In actual plugin development,
     *      you can directly use the Preferences pointer without calling these functions.
     */
    vector<string>* getHostName();
    vector<string>* getProtocolUrl();
    string getChcpConfigUrl();
    bool getAllAllowUpdatesAutoDownload();
    bool getAllowUpdatesAutoInstall();
    int getActiveInterfaceVersion();
    void getCameraImageCompress(bool& isCameraImageCompress, long & lngCompressImageSize, string& strCameraCompressShowToast);
    long getCordovaCacheDuration();
    string getIonicHostName();
    string getIonicScheme();
};
#endif